#include "TH1D.h"
#include <vector>
#include <iostream>
#include "TROOT.h"
#include "TMath.h"
#include "TCanvas.h"
#include "TRandom.h"
#include "TF1.h"
#include "TFile.h"
#include "TChain.h"
#include "TClonesArray.h"
#include "TLorentzVector.h"
#include "TString.h"

using namespace std;
class FlowToyMCBase
{
public:
FlowToyMCBase();
~FlowToyMCBase();
void Init(); 
void Generate4Vector();  
void GeneratePhi();  
void SetNPar(int NPar);
void SetInputVn(double v3, double v2, double v1=0, double v0=0);
void SetDetResol(double Det_resol);
void SetEP();
void SetEP_Measured(int nh, double EP);
void SetDetName(char* DetName);
void SetPtDist(TF1* PtDist);  
void SetRapidityRange(double YMax);  
void SetMass(double Mass); 

void Print();
void SetEPSeed(int Seed);
double GetQx(int nh);
double GetQy(int nh);
double GetEP_Input(int nh);
double GetEP_Measured(int nh);
double GetVn_Input(int nh);
double GetVn_Measured(int nh);
double GetPhi(int iPar);
double GetPx(int iPar); 
double GetPy(int iPar); 
double GetPz(int iPar);
double GetE(int iPar); 
double GetPt(int iPar);
double GetRapidity(int iPar); 
TClonesArray* GetParticleArray();
double GetNPar();
double Get_Resol(int nh);
double Cal_EP(int nh);
double Cal_EPSub(int nh, int ipar_from, int ipar_to);
double Cal_Vn(int nh);
double Cal_VnReal(int nh);
double Cal_Resol(int nh);
double Cal_Sub2Resol(int nh);
double* Cal_Sub3Resol(int nh, int sub1, int sub2);
TLorentzVector* Get4Vector(int iPar); 

private:
// ******** Flow setting Parameters ***************
double fNPar;
enum {fNH=4};   //Nharmonic max
//static const int fNH = 4;
double fMass;  
double fYMax;  
double fVn_Input[fNH];
double fEP_Input[fNH];
double fDet_resol;
double fVn_Measured[fNH];
double fVn_MeasuredReal[fNH];
double fEP_Measured[fNH];
double fResol[fNH];
double fSub2Resol[fNH];
double fSub3Resol[fNH][3];
double fQx[fNH];
double fQy[fNH];
vector <double> fPhis;
char *fDetName;
TRandom fMyRandom;  
TF1 *fdNdphi_bulk;
TF1 *fPtDist;   
TClonesArray *fArray; 
};
